{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入数字\n",
      "我都会执行\n"
     ]
    }
   ],
   "source": [
    "import time\n",
    "\n",
    "try:\n",
    "    year = int(time.strftime('%Y'))\n",
    "    y = int(input(\"请输入年份：\"))\n",
    "    print(\"你的年纪是：{}\".format(year-y))\n",
    "except ValueError:\n",
    "    print(\"请输入数字\")\n",
    "finally:\n",
    "    print(\"我都会执行\")\n",
    "\n",
    "# 经常遇到的异常\n",
    "NameError\n",
    "ValueError\n",
    "TypeError\n",
    "KeyError\n",
    "IndexError\n",
    "SyntaxError\n"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "ff79ebfcf6806606a412477be2872c3ec52671763ecb054ca3010c66083164a3"
  },
  "kernelspec": {
   "display_name": "Python 3.8.3 ('base')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
